package cn.hchaojie.javase.day01.exercise;

public class Ex4 {
	public static void main(String[] args) {
		// 取到年月值
		if (args.length < 2) {
			System.out.println("请输入年份和月份两个参数");
			System.exit(-1);
		}
		
		int year = Integer.parseInt(args[0]);
		int month = Integer.parseInt(args[1]);
		
		int days = 0;
		// 判断月份
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			days = 31;
			break;
			
		case 2:
			boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
//			if (isLeapYear) {
//				days = 29;
//			} else {
//				days = 28;
//			}
			
			days = (isLeapYear) ? 29 : 28;
			break;
			
		case 4:
		case 6:
		case 9:
		case 11:
			days = 30;
			break;

		default:
			break;
		}
		
		System.out.println(days);
	}
}
